package com.maycurobj.repository.bim;

import com.maycurobj.entity.bim.IamLeaveUser;
import com.maycurobj.entity.bim.Tbtacc;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 获取IAM 离职信息
 */
@Repository
public interface IamLeaveUserRepository extends JpaRepository<IamLeaveUser, String> {

    /**
     * 获取统一系统中对应的钉钉userid by hrID
     * @param days
     * @return
     */
    @Query(nativeQuery = true, value= "select TACC_FULLNAME as name,X_MOBILE as mobile,X_EMPLOYEENO as employeeno from tb_tacc LEFT JOIN tb_tacc_x_apphub on tb_tacc.TACC_ID=tb_tacc_x_apphub.TACC_ID where TSYS_ID='20190715165449742-4B3E-F38C10E5D' and TACC_IS_DISABLED=1 and tb_tacc_x_apphub.X_EMPLOYEENO is not null  AND TACC_UPDATE_AT >= DATE_SUB(NOW(), INTERVAL :days DAY) ")
    List<IamLeaveUser> getLists(@Param(value = "days") int days);



}
